﻿Public Class BookSearch
    Inherits System.Web.UI.Page
    Dim sach As New Sach_BLL()
    Dim p As New Sach_DTO()
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        loadKQTimKiem()
    End Sub
    Public Sub loadKQTimKiem()
        p._text = RemoveSign4VietnameseString(Request.QueryString("search"))
        dtl_timkiem.DataSource = sach.timkiemSach(p)
        dtl_timkiem.DataBind()
    End Sub

    'Tham Khao https://sites.google.com/site/dttrungit/baihuongdan/lap-trinh/01-vb-net/loai-bo-tieng-viet-trong-vb-net
    Private Shared ReadOnly VietnameseSigns As String() = New String() {"aAeEoOuUiIdDyY", "áàạảãâấầậẩẫăắằặẳẵ", "ÁÀẠẢÃÂẤẦẬẨẪĂẮẰẶẲẴ", "éèẹẻẽêếềệểễ", "ÉÈẸẺẼÊẾỀỆỂỄ", "óòọỏõôốồộổỗơớờợởỡ", _
                                                                            "ÓÒỌỎÕÔỐỒỘỔỖƠỚỜỢỞỠ", "úùụủũưứừựửữ", "ÚÙỤỦŨƯỨỪỰỬỮ", "íìịỉĩ", "ÍÌỊỈĨ", "đ", _
                                                                            "Đ", "ýỳỵỷỹ", "ÝỲỴỶỸ"}

    Public Shared Function RemoveSign4VietnameseString(ByVal str As String) As String
        For i As Integer = 1 To VietnameseSigns.Length - 1
            For j As Integer = 0 To VietnameseSigns(i).Length - 1
                str = str.Replace(VietnameseSigns(i)(j), VietnameseSigns(0)(i - 1))
            Next
        Next
        Return str
    End Function
End Class